<?php
/**
 * @author 段志岩
 * @date 2008.8.18
 * @summary 会话类，封装了$_SESSION数组.
 */

class Session extends Base{
	private $session;
	private static $instance = null;

	private function __construct()
	{
		session_start();
		$this->session = &$_SESSION;
	}
	public static function getSession()
	{
		if(Session::$instance == null)
		{
			Session::$instance = new Session();
		}
		return Session::$instance;
	}
	public function setAttr($name, $value)
	{
		$this->session[$name] = $value;
	}
	public function getAttr($name)
	{
		if(array_key_exists($name, $this->session))
		{
			return $this->session[$name];
		}
		return null;
	}
	public function destroy()
	{
		session_unset();
		session_destroy();
	}
};
?>
